#ifndef CHARACTER_H
#define CHARACTER_H

class Character: public GameObject
{
public:
	u16 _oldx;
	u16 _oldy;
	u8 _curHealth;
	u8 _maxHealth;
	u16 _speed; 
	void Move(u16 x, u16 y);
	void Render(uint16 *fb, u16 x, u16 y, u16 palette[], u8 sprites[][256], u8 frame);
	Character() {_curHealth = 12; _maxHealth = 12; _oldx = 0; _oldy = 0; _speed = 2;}
};

void Character::Move(u16 x, u16 y)
{
	_x = _x + x;
	_y = _y + y;
}

void Character::Render(uint16 *fb, u16 x, u16 y, u16 palette[], u8 sprites[][256], u8 frame)
{
	// Starting point in buffer
	u8 t = 0;
	for(unsigned short yy = y; yy < y+16; yy++)
	{
		for(unsigned short xx = x; xx < x+16; xx++)
		{
			if(sprites[frame][t] > 0) // Not transparent 
			{
				fb[yy*SCREEN_WIDTH+xx] = palette[sprites[frame][t]];
			}
			t++;
		}
	}
}

#endif //CHARACTER_H